package com.rongji.cms.tools.common.vo;

import com.rongji.cms.tools.common.enums.CommonResultCode;
import com.rongji.cms.tools.common.enums.StatusCode;
import lombok.Data;

/**
 * 统一响应结果封装
 */

@Data
public class ResultVO {

    /**
     * 状态码，比如200代表响应成功
     */
    private int code;
    /**
     * 响应信息，用来说明响应情况
     */
    private String msg;
    /**
     * 响应的具体数据
     */
    private Object data;



    private ResultVO() {
    }

    public   ResultVO (CommonResultCode commonResultCode){
        this.code=commonResultCode.getCode();
       this.msg=commonResultCode.getMsg();
    }

    public ResultVO(int code,String msg, Object data) {
        this.code = code;
        this.msg = msg;
        this.data = data;
    }

   public static  ResultVO success(){
        ResultVO resultVO=new ResultVO();
       resultVO.setCode(CommonResultCode.SUCCESS.getCode());
       resultVO.setMsg(CommonResultCode.SUCCESS.getMsg());

        return  resultVO;
   }

   public static  ResultVO success(Object data){
       ResultVO resultVO=new ResultVO();
       resultVO.setCode(CommonResultCode.SUCCESS.getCode());
       resultVO.setMsg(CommonResultCode.SUCCESS.getMsg());
       resultVO.setData(data);
       return  resultVO;
   }



    public static  ResultVO fail(int code,String msg){
        ResultVO resultVO=new ResultVO();
        resultVO.setCode(code);
        resultVO.setMsg(msg);

        return  resultVO;
    }

    public static  ResultVO fail(int code,String msg,Object data){
        ResultVO resultVO=new ResultVO();
        resultVO.setCode(code);
        resultVO.setMsg(msg);
        resultVO.setData(data);
        return  resultVO;
    }


}
